Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MkInstallGuide

github Show source on GitHub

Node to display an install guide.

Examples

Example: Regular

Note

Jinja

{{ mk.MkInstallGuide() }}

Note

Python

MkInstallGuide()
Rendered

pip

The latest released version is available at the Python package index.

pip install mknodes

pipx

pipx allows for the global installation of Python applications in isolated environments.

pipx install mknodes
Markdown

Html

Example: Explicit

Note

Jinja

{{ "mkdocs" | MkInstallGuide(package_repos=["pip", "pipx"]) }}

Note

Python

MkInstallGuide('mkdocs', package_repos=['pip', 'pipx'])
Rendered

pip

The latest released version is available at the Python package index.

pip install mkdocs

pipx

pipx allows for the global installation of Python applications in isolated environments.

pipx install mkdocs
Markdown
### pip

The latest released version is available at the [Python package index](https://pypi.org/project/mkdocs).

````python
pip install mkdocs
````
### pipx

[pipx](https://github.com/pypa/pipx) allows for the global installation of Python applications in isolated environments.

````python
pipx install mkdocs
````

Html
<h3 id="pip">pip<a href="#pip" aria-label="Link to heading 'pip'" data-heading-content="pip" class="anchor"></a></h3>
<p>The latest released version is available at the <a href="https://pypi.org/project/mkdocs">Python package index</a>.</p>
<pre><code class="language-python">pip install mkdocs
</code></pre>
<h3 id="pipx">pipx<a href="#pipx" aria-label="Link to heading 'pipx'" data-heading-content="pipx" class="anchor"></a></h3>
<p><a href="https://github.com/pypa/pipx">pipx</a> allows for the global installation of Python applications in isolated environments.</p>
<pre><code class="language-python">pipx install mkdocs
</code></pre>

Repr tree
MkInstallGuide
├── MkHeader('pip', level=3)
├── MkCode(None)
│   ╰── MkText('pip install mkdocs')
├── MkHeader('pipx', level=3)
╰── MkCode(None)
    ╰── MkText('pipx install mkdocs')
DocStrings

class MkInstallGuide(mktemplate.MkTemplate)
Base classes
⋔ Inheritance diagram
graph TD
  2805510712["mkinstallguide.MkInstallGuide"]
  1289759389["mktemplate.MkTemplate"]
  3160803176["rendercache.TemplateRenderMixin"]
  2751680898["builtins.object"]
  835538629["mkcontainer.MkContainer"]
  1956333208["mkcontainer.MkContainerBase"]
  1359323199["mknode.MkNode"]
  1289759389 --> 2805510712
  3160803176 --> 1289759389
  2751680898 --> 3160803176
  835538629 --> 1289759389
  1956333208 --> 835538629
  1359323199 --> 1956333208
  2751680898 --> 1359323199
NodeFile

/home/runner/work/mknodes/mknodes/src/mknodes/templatenodes/mkinstallguide/metadata.toml

[metadata]
name = "MkInstallGuide"
icon = "mdi:help"
group = "documentation"
virtual_children = true

[examples.regular]
title = "Regular"
jinja = """
{{ mk.MkInstallGuide() }}
"""

[examples.explicit]
title = "Explicit"
jinja = """
{{ "mkdocs" | MkInstallGuide(package_repos=["pip", "pipx"]) }}
"""

[output.markdown]
template = """
{% for method in node.package_repos %}
{{ method.ID | MkHeader(level=node.header_level) }}

{{ method.info_text() }}

{{ method.install_instructions() | MkCode }}
{% endfor %}
"""

# proj = self.associated_distribution
# if method.ID == "pip" and proj and (extras := proj.info.extras):
#     extras_str = ",".join(extras)
#     text = f"{method.install_instructions()}[{extras_str}]"
#     code = mkcode.MkCode(text)
#     items.append(code)

Code

mknodes.templatenodes.mkinstallguide.MkInstallGuide

class MkInstallGuide(mktemplate.MkTemplate):
    """Node to display an install guide."""

    ICON = "material/help"
    VIRTUAL_CHILDREN = True

    def __init__(
        self,
        distribution: str | None = None,
        *,
        package_repos: list[installmethods.InstallMethodStr] | None = None,
        header_level: int = 3,
        **kwargs: Any,
    ) -> None:
        """Constructor.

        Args:
            distribution: name of the distribution to install
            package_repos: package repositories the project is available on
            header_level: Header level for each section
            kwargs: Keyword arguments passed to parent
        """
        super().__init__("output/markdown/template", **kwargs)
        self._distribution = distribution
        self.header_level = header_level
        self._package_repos = package_repos

    @property
    def package_repos(self) -> list[installmethods.InstallMethod]:
        if self._package_repos:
            return [
                installmethods.InstallMethod.by_id(i)(self.distribution)
                for i in self._package_repos
            ]
        return self.ctx.metadata.package_repos or []

    @property
    def distribution(self):
        return self._distribution or self.ctx.metadata.distribution_name

    @distribution.setter
    def distribution(self, value) -> None:
        self._distribution = value

Page info
Code for this page

mknodes.manual.nodes_section.create_section_for_nodes

def create_section_for_nodes(
    nav: mk.MkNav,
    klasses: Sequence[type[mk.MkNode]],
) -> mk.MkTable:
    table = mk.MkTable(columns=["Node", "Docstrings", "Markdown extensions"])
    for kls in klasses:
        tpl = "classpage_custom.jinja"
        page = mk.MkClassPage(kls, icon=kls.ICON, template_path=tpl, parent=nav, hide="toc")
        nav += page
        if kls.STATUS:
            page.metadata.status = kls.STATUS
        elif kls.JS_FILES:
            page.metadata.status = "js"
        elif kls.CSS:
            page.metadata.status = "css"
        page.created_by = create_section_for_nodes
        link = mk.MkLink(page, kls.__name__, icon=kls.ICON)
        extensions = ", ".join(f"`{i}`" for i in kls.REQUIRED_EXTENSIONS)
        table.add_row((link, kls.__doc__, extensions))
    return table

Resources
Resources(css=[],
          markdown_extensions={'admonition': {},
                               'pymdownx.details': {},
                               'pymdownx.highlight': {'anchor_linenums': True,
                                                      'line_spans': '__span',
                                                      'pygments_lang_class': True},
                               'pymdownx.superfences': {'custom_fences': [{'class': 'mermaid',
                                                                           'format': <function fence_code_format at 0x7d707a397060>,
                                                                           'name': 'mermaid'}]},
                               'pymdownx.tabbed': {},
                               'tables': {}},
          plugins=[Plugin('mkdocstrings')],
          js=[],
          assets=[],
          packages=[])
Metadata
created:
  source_filename: /home/runner/work/mknodes/mknodes/src/mknodes/manual/nodes_section.py
  source_function: create_section_for_nodes
  source_line_no: 93
hide:
- toc
icon: material/help
status: new
title: MkInstallGuide